package priv.yiyuan.example.design;

import priv.yiyuan.example.design.device.Device;

/**
 * 调整等级命令
 *
 * @author YiYuan
 * @data 2025/8/20
 * @apoNote
 */
public class AdjustLevelCommand implements Command {

    private Device device;

    private int prevLevel;

    private int newLevel;

    public AdjustLevelCommand(Device device, int newLevel) {
        this.device = device;
        this.newLevel = newLevel;
    }

    @Override
    public void execute() {

        prevLevel = newLevel;
        device.adjust(newLevel);

    }

    @Override
    public void undo() {
        System.out.println("取消调整，恢复到以前的状态");
        device.adjust(0);
    }
}
